package com.ww.springboot.boot.javabase.stream;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * 描述：
 *
 * @author 🧑 ‍wanwei
 * @since 2023-06-21 11:36
 */
public class StreamDemo4 {
    public static void main(String[] args) {
        List<Integer> list = IntStream.range(0, 100).boxed().collect(Collectors.toList());
        System.out.println(list.stream().reduce((a, b) -> a + b).get());
        System.out.println(list.stream().reduce(100, (a, b) -> a + b));
        //3参数方法用于并行流
        System.out.println(list.parallelStream().reduce(0,(a, b) -> {
            System.out.println(Thread.currentThread());
            System.out.println(a + "-" + b);
            return a + b;
        },(a, b) -> a + b));

    }
}
